<template>
	<!-- 球馆 statr -->
	<view class="meadowlands">
		<view class="bg1">
			<view></view>
		</view>
		<view class="dian"></view>
		<uv-navbar leftIconColor="#FFFFFF" bgColor="transparent" title="助教列表" :fixed="true" :placeholder="true"
			:titleStyle="{
				'font-weight': 'bold',
				'font-size': '32rpx',
				'color': '#FFFFFF'
			}" @leftClick="back" />
		<view class="list">
			<scroll-view class="scroll-content" :scroll-y="true" @scrolltolower="getList">
				<view class="item" v-for="(item,index) in list" :key="index"
					@click="navTo('/pages/help/detail?user_id='+item.user_id)">
					<view class="left">
						<image :src="item.avatar" mode="aspectFill"></image>
						<view class="sundries">
							<view class="name">{{item.assistant_name}}</view>
							<view class="tip">{{item.signature}}</view>
						</view>
					</view>
					<view class="right">{{item.price}} 元/分钟</view>
				</view>
			</scroll-view>

		</view>
	</view>
	<!-- 球馆 end -->
</template>

<script>
	import {
		goLogin,
		checkLogin
	} from '@/libs/login';
	export default {
		data() {
			return {
				currentIndex: 0,
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				list: [],
				params: {
					page: 1,
					limit: 10
				}
			}
		},
		onShow() {
			let theme = uni.getStorageSync('theme')
			this.fontColor = theme.color
			this.themeBg = 'linear-gradient(90deg, ' + theme.bg1 + ', ' + theme.bg2 + ')'
			this.isLogin = this.$store.getters.isLogin
			console.log("this.isLogin", this.isLogin)
			// if (this.isLogin) {
			this.getList()
			// }
		},
		methods: {
			//获取助教列表
			async getList() {
				uni.showLoading({
					title: '请稍后'
				})
				let res = await this.$api.meadowlands.getAssistant.get({
					...this.params
				})

				uni.hideLoading()

				if (res.code == 0) {
					// this.$tool.success(res.msg);
					if (res.data.length == 0) {
						// uni.showToast({
						// 	title: "已加载全部助教！"
						// })
						return
					}
					this.list = [...res.data]
					this.params.page += 1
				} else {
					this.$tool.error(res.msg);
				}

				uni.hideLoading()
			},
			back() {
				uni.navigateBack({
					delta: 1
				});
			},
			async update() {
				uni.showLoading({
					title: "加载中。。。"
				})
				let res = await this.$api.meadowlands.getAssistant.get({
					limit: 10
				})

				if (res.code == 0) {
					if (res.data.length <= 0) {
						uni.showLoading({
							title: "已加载全部助教！"
						})
					}
				}
				uni.hideLoading();
			},
			handleSwiperChange(e) {
				this.currentIndex = e.detail.current;
			},
			navTo(url) {
				uni.navigateTo({
					url
				})
				return
				if (!this.isLogin) {
					goLogin();
				}


			},
		}
	}
</script>

<style lang="scss">
	page {
		overflow: hidden;
	}

	.meadowlands {
		background: #240F41;
		color: #FFFFFF;
		min-height: 100vh;

		.bg1 {
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: center;
			position: absolute;
			left: calc(50%-59px);

			view {
				width: 118px;
				height: 118px;
				background: linear-gradient(90deg, #C829F3 0%, #4516CA 100%);
				box-shadow: inset 0rpx 8rpx 8rpx 0rpx rgba(0, 0, 0, 0.25);
				border-radius: 0rpx 0rpx 0rpx 0rpx;
				opacity: 0.9;
				filter: blur(90px);
			}
		}

		.dian {
			width: 118px;
			height: 118px;
			background: linear-gradient(90deg, #1F87EF 0%, #1F87EF 100%);
			box-shadow: inset 0rpx 8rpx 8rpx 0rpx rgba(0, 0, 0, 0.25);
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			opacity: 0.9;
			filter: blur(90px);
			position: absolute;
			left: 0;
			top: 20px;
		}

		.list {
			padding: 0 26rpx 26rpx 26rpx;
			margin-top: 34rpx;
			height: calc(100vh - 130rpx);

			.scroll-content {
				height: 100%;
			}

			.item {
				width: 100%;
				height: 160rpx;
				background: linear-gradient(313deg, #5A25F0 0%, #C69CFD 100%);
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 32rpx;

				.left {
					display: flex;
					flex-direction: row;
					align-items: center;
					padding-left: 16rpx;

					image {
						width: 128rpx;
						height: 128rpx;
						border-radius: 116rpx 116rpx 116rpx 116rpx;
						border: 2rpx solid #9A24B9;
					}

					.sundries {
						margin-left: 20rpx;

						.name {
							font-weight: bold;
							font-size: 32rpx;
							color: #FFFFFF;
						}

						.tip {
							width: 226rpx;
							height: 32rpx;
							background: linear-gradient(128deg, #6BEAFF 0%, #86FFDE 100%);
							border-radius: 48rpx 48rpx 48rpx 48rpx;
							font-weight: 400;
							font-size: 22rpx;
							color: #333333;
							text-align: center;
							white-space: nowrap;
							/* 强制文本不换行 */
							overflow: hidden;
							/* 隐藏超出部分 */
							text-overflow: ellipsis;
							padding: 0 16rpx;
							margin-top: 16rpx;
						}
					}
				}

				.right {
					padding-right: 32rpx;
					font-weight: 500;
					font-size: 32rpx;
					color: #FFFFFF;
				}
			}
		}
	}
</style>